﻿/* * 版 本 PIT-ADMS V7.0.3 敏捷开发框架
 * Copyright (c) 2013-2018 Hexagon PPM
 * 创建人：超级管理员
 * 日  期：2022-08-23 17:31
 * 描  述：命名规则，与对象类型和属性都有关联
 */

var refreshGirdData;
var ProjectId = request('ProjectId');
var selectData = [];
var ObjectTypeID = request('ObjectTypeID');
var bootstrap = function ($, learun) {
    "use strict";
    var page = {
        init: function () {
            page.initGird();//初始化grid
            page.bind();
        },
        bind: function () {
            // 查询
            $('#btn_Search').on('click', function () {
                var keyword = $('#txt_Keyword').val();
                page.search({ keyword: keyword });
            });
            // 刷新
            $('#lr_refresh').on('click', function () {
                location.reload();
            });
            // 新增
            $('#lr_add').on('click', function () {
                learun.layerForm({
                    id: 'form',
                    title: '新增',
                    url: top.$.rootUrl + '/ZZDT_EC/ec_objecttypenamingconv/Form?ObjectTypeID=' + ObjectTypeID + '&ProjectId=' + ProjectId,
                    width: 400,
                    height: 400,
                    callBack: function (id) {
                        return top[id].acceptClick(refreshGirdData);//top作用是取得最顶层框架对象
                    }
                });
            });
            // 编辑
            $('#lr_edit').on('click', function () {
                var keyValue = $('#gridtable').jfGridValue('ObjectTypeNVID');
                /*learun.alert.success(keyValue);*/
                if (learun.checkrow(keyValue)) {
                    learun.layerForm({
                        id: 'form',
                        title: '编辑',
                        url: top.$.rootUrl + '/ZZDT_EC/ec_objecttypenamingconv/Form?keyValue=' + keyValue + '&ProjectId=' + ProjectId + '&ObjectTypeID=' + ObjectTypeID,
                        width: 400,
                        height: 400,
                        callBack: function (id) {
                            return top[id].acceptClick(refreshGirdData);
                        }
                    });
                }
            });
            // 删除
            $('#lr_delete').on('click', function () {
                var keyValue = $('#gridtable').jfGridValue('ObjectTypeNVID');
                if (learun.checkrow(keyValue)) {
                    learun.layerConfirm('是否确认删除该项！', function (res) {
                        if (res) {
                            learun.deleteForm(top.$.rootUrl + '/ZZDT_EC/ec_objecttypenamingconv/DeleteForm', { keyValue: keyValue, ProjectId: ProjectId }, function () {
                                refreshGirdData();
                            });
                        }
                    });
                }
            });
        },
        initGird: function () {
            var param = {};//声明一个没有任何属性的对象
            param.ProjectId = ProjectId;
            param.ObjectTypeID = ObjectTypeID;
            $('#gridtable').jfGrid({
                url: top.$.rootUrl + '/ZZDT_EC/ec_objecttypenamingconv/GetList?queryJson=' + JSON.stringify(param),
                //列设置
                headData: [
                    //{ label: 'ObjectTypeID', name: 'ObjectTypeID', width: 200, align: "left" },
                    //{ label: 'ObjectTypePID', name: 'ObjectTypePID', width: 200, align: "left" },
                    { label: '属性显示名', name: 'ObjectTypePName', width: 200, align: "left" },
                    { label: '顺序', name: 'Segmentno', width: 50, align: "left" },
                    { label: '长度', name: 'Length', width: 50, align: "left" },
                    { label: '分隔符', name: 'Sepator', width: 50, align: "left" },
                    { label: '类型', name: 'Segmenttype', width: 100, align: "left" },
                ],
                mainId: 'ObjectTypeNVID',//关联的主键
                isPage: false //这里不能有isPage=true，否则前台会报一个length的错误
            });
            page.search();
        },
        search: function (param) {
            param = param || {};
            $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
        }
    };
    refreshGirdData = function () {
        $('#gridtable').jfGridSet('reload');
    };
    page.init();
}
